let managerAccount = document.getElementById("account").addEventListener("click", () => {
    document.location = "./ManagerAccount.html"
})
let post = document.getElementById("post").addEventListener("click", () => {
    document.location = "./ManagerPost.html"
})
let assign = document.getElementById("assignTasks").addEventListener("click", () => {
    document.location = "./ManagerAssign.html"
})
let backToManagerDashboard = document.getElementById("backToManagerDashboard")
if (backToManagerDashboard) {
    backToManagerDashboard.addEventListener("click", () => {
        document.location = "./ManagerDashboard.html"
    })
}

let changeNightModeStatus = document.getElementById("NightModeBGI").addEventListener("click", (event) => {


    if (event.target.style.backgroundImage == "url(\"../images/close.svg\")") {
        event.target.style.backgroundImage = "url('../images/open.svg')"
        document.getElementById("html").style.backgroundImage = "url('../images/bgIMG_night.jpg')"
        Cookies.set("nightmode","1")
    } else {
        event.target.style.backgroundImage = "url('../images/close.svg')"
        document.getElementById("html").style.backgroundImage = "url('../images/bgIMG.jpg')"
        Cookies.set("nightmode","0")
    }

})
let getNightModeStatus = function () {


}

let managerLogout=document.getElementById("managerLogout")

managerLogout.addEventListener("click", (event => {
    $.post("/pub/managerLogout",
        null,
        function (res) {
            if (res.status.startsWith("4")) {
                alert(res.message)
                document.location = "/public/html/home.html"
            } else {
                alert(res.message)
                document.location = "/public/html/home.html"
            }
        }, "json");
}))

window.addEventListener("load",()=>{
    let managerLoginNumberAndName =document.getElementById("managerLoginNumberAndName")
    if (managerLoginNumberAndName) {
        managerLoginNumberAndName.innerText=`Manager ID:${Cookies.get('id')} Name:${Cookies.get('username')}`

    }
    if(Cookies.get("nightmode")==1) {
        document.getElementById("NightModeBGI").style.backgroundImage = "url('../images/open.svg')"
        document.getElementById("html").style.backgroundImage = "url('../images/bgIMG_night.jpg')"
    }
    else {
        document.getElementById("NightModeBGI").style.backgroundImage = "url('../images/close.svg')"
        document.getElementById("html").style.backgroundImage = "url('../images/bgIMG.jpg')"
    }
})


